<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/6/6
  Time: 13:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--分页标签 -->
<%@ taglib prefix="page" uri="/xianzhiOA/pageTag" %>
<%@ taglib prefix="p" uri="/xianzhiOA/powerTag" %>
<html>
<head>
    <title>角色分配</title>
    <script type="application/javascript"
            src="${pageContext.request.contextPath}/dist/backEnd/js/jquery-2.1.1.min.js"></script>
    <!--弹出框需要导入的css-->
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/dist/backEnd/css/popup/common.css"/>
    <script type="application/javascript">
        function pToSub(page) {
            if (page != undefined) {
                var pageInp = document.getElementById("page");
                pageInp.value = page;
                var form = document.getElementById("roleAllotForm");
                form.submit();
            }
        }

        function deleteCheck(empId) {
            if (confirm("确定要删除吗？")) {
                var roleAllotForm = document.getElementById("roleAllotForm");
               // window.location.href = "${pageContext.request.contextPath}/XzEmp/deleteEmp.emp?empId=" + empId;
            }
        }

        <%--window.onload=function () {--%>

            <%--if("${auditStatus}" != null && "${auditStatus}" !=""){--%>
                <%--var auditStatus="${auditStatus}";--%>
                <%--auditStatus=parseInt(auditStatus)+1;--%>
                <%--var all_options = document.getElementById("auditStatus").options;--%>
                <%--all_options[auditStatus].selected=true;--%>
            <%--}--%>
        <%--}--%>
        //       弹出框开始
        var w,h,className;
        function getSrceenWH(){
            w = $(window).width();
            h = $(window).height();
            $('#dialogBg').width(w).height(h);



        }

        window.onresize = function(){
            getSrceenWH();
        }

        $(window).resize();

        $(function(){
            getSrceenWH();

            //显示弹框
//            $('.showA').click(function(){
//
//                className = $(this).attr('class');
//                $('#dialogBg').fadeIn(300);
//                $('#dialog').removeAttr('class').addClass('animated '+className+'').fadeIn();
//            });


            //关闭弹窗
            $('.claseDialogBtn').click(function(){
                $('#dialogBg').fadeOut(300,function(){
                    $('#dialog').addClass('bounceOutUp').fadeOut();
                });
            });
        });

        //显示弹框
        function showBox(Selected,roleId) {

            <%--var auditStatus="${auditStatus}";--%>
            <%--auditStatus=parseInt(auditStatus)+1;--%>
            <%--var all_options = document.getElementById("auditStatus").options;--%>
            <%--all_options[auditStatus].selected=true;--%>

            <%--var templetBaseInfoId="${templetBaseInfoId}";--%>

            className = $(this).attr('class');
            $('#dialogBg').fadeIn(300);
            $('#dialog').removeAttr('class').addClass('animated '+className+'').fadeIn();

            Selected=parseInt(Selected)-2;
            var all_options = document.getElementById("box_auditStatus").options;
            all_options[Selected].selected=true;
            document.getElementById("test_input").value=roleId;
        }

        //弹出框的修改状态事件
        //        function updateState() {
        //           var test_input=document.getElementById("test_input").value;
        //            alert("test_input:"+test_input);
        //
        //        }



        //       弹出框结束
    </script>

</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<!--内容页-->
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="two.html"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>基本信息</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>
    <form action="${pageContext.request.contextPath}/XzEmp/roleAllotShow.emp" class="search1" id="roleAllotForm" method="post">
        <div>

            <div style="margin-top: 10px">
                <input id="page" name="page" type="hidden" value="${page}">
                <input id="pages" name="pages" type="hidden" value="${pages}">
                <input type="text" placeholder="姓名..." name="empName" value="${Emp.empName}">
                <%--<input type="text" placeholder="角色..." name="empRole" value="${Emp.empRole}">--%>
                <input type="text" placeholder="员工账户..." name="empAccount" value="${Emp.empAccount}">
                <select name="empRole">
                    <option  value="0">—请选择查询条件—</option>
                    <c:forEach items="${RoleList}" var="r">
                        <c:if test="${r.roleId != 1}">
                            <option value="${r.roleId}" name="${Emp.role.roleId}" <c:if test="${Emp.empRole==r.roleId}">selected="selected"</c:if>>${r.roleName}</option>
                        </c:if>
                    </c:forEach>
                </select>
                <button type="submit" class="one"><span class="fa fa-search"></span></button>
                <a href="${pageContext.request.contextPath}/XzEmp   /roleAllotShow.emp" class="three btn btn-primary">重置</a>
            </div>
            <!--表格-->
            <div class="well">
                <table class="table" id="now">
                    <thead>
                    <tr>
                        <th class="d">员工工号</th>
                        <th class="d">姓名</th>
                        <th class="d">角色</th>
                        <th class="d">员工账户</th>
                        <p:power jspPower="角色分配：分配角色">
                            <th class="dd">分配角色</th>
                        </p:power>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="Emp" items="${EmpList}">
                        <tr>
                            <td style="display: none">${Emp.empId}</td>
                            <td>${Emp.empNo}</td>
                            <td>${Emp.empName}</td>
                            <td>${Emp.role.roleName}</td>
                            <td>${Emp.empAccount}</td>
                            <p:power jspPower="角色分配：分配角色">
                                <td><a class="showA" onclick="showBox(${Emp.role.roleId},${Emp.empId})"><i class="fa fa-cogs"></i></a></td>
                            </p:power>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <!--分页符-->
            <div style="float: right">
                <ul class="pagination">
                    <page:paging length="10" page="${page}" pages="${pages}"/>
                </ul>
            </div>

        </div>
    </form>
</div>
<!--弹出框-->
<div class="box">

    <div id="dialogBg"></div>
    <div id="dialog" class="animated">
        <img class="dialogIco" width="50" height="50" src="${pageContext.request.contextPath}/dist/backEnd/img/popup/ico.png" alt="" />
        <div class="dialogTop">
            <a href="javascript:;" class="claseDialogBtn">关闭</a>
        </div>
        <form action="${pageContext.request.contextPath}/XzEmp/updateEmpRole.emp" method="post" id="editForm">
            <ul class="editInfos">

                <li><label><font color="#ff0000">* </font>状态：
                    <select name="empRole" id="box_auditStatus">
                        <c:forEach items="${RoleList}" var="r">
                            <option value="${r.roleId}">${r.roleName}</option>
                        </c:forEach>
                    </select>

                </label></li>
                <li><button type="submit" class="btn btn-success">确认提交</button></li>
            </ul>
            <input type="hidden" id="test_input" name="empId"/>
        </form>
    </div>
</div>
</body>
</html>
